<template>
  <div class="pointsoperateBranch">
    <topBar :title="title"></topBar>
    <div class="echarts">
      <div class="bot">
        <div v-for="(item, index) in lineDatas" :key="index">
          <lineEcharts :id="'lineechart' + index" :lineData="item"></lineEcharts>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import topBar from "./topBar";
import lineEcharts from "../showEchart/lineEcharts";
import { pointCounty } from "@/api/codeIncome/analysis";
export default {
  name: "pointsoperateBranch",
  components: {
    topBar,
    lineEcharts,
  },
  props: {
    searchData: {
        type: Object,
        default: {},
    },
  },
  watch: {
    searchData: {
        handler(newName) {
            this.getlineData()
        },
        deep: true,
    },
  },
  data() {
    return {
      title: "码号收入 – 分经营单元（分局）",
      lineDatas:[]
    };
  },
  created() {},
  mounted() {
      this.getlineData()
  },
  methods: {
      getlineData() {
        this.lineDatas = []
        pointCounty({
        acctMonth: this.searchData.acctMonth,
        areaId: this.searchData.areaId,
        flag: 3
      }).then(res => {
            if (res.code == 200) {
                let data = res.data
                let arr = []
                data.forEach(item => {
                    let obj = {}
                    obj['title'] = item.characterList[0].text
                    obj['lastdata'] = item.dataList[0].datas
                    obj['indata'] = item.dataList[1].datas
                    arr.push(obj)
                });
                this.lineDatas = arr
            }
        })
    }
  },
};
</script>
<style scoped>
.pointsoperateBranch {
    box-sizing: border-box;
    padding: 20px;
    box-shadow: 0px 0px 10px 1px rgb(0 0 0 / 15%);
}
</style>
<style scoped lang="scss">
.pointsoperateBranch {
  margin-top: 20px;
  .echarts {
    width: 100%;
    height: auto;
    .bot {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-start;
      > div {
        width: 33.33%;
        height: 200px;
      }
    }
  }
}
</style>
